package DesignPattern;

/**
 * 模板方法
 */
public abstract class PatternMethod {
    //做饭
    public void run() {
        //洗菜
        wash();

        //切菜
        cut();

        //做菜
        play();

        //吃饭
        eat();
    }

    protected abstract void wash();
    protected abstract void cut();
    protected abstract void play();
    protected abstract void eat();

    public static void main(String[] args) {
        PatternMethod patternMethod = new I();
        patternMethod.run();
    }
}

class I extends PatternMethod{
    @Override
    protected void wash() {
        System.out.println("I wash");
    }

    @Override
    protected void cut() {
        System.out.println("I cut");
    }

    @Override
    protected void play() {
        System.out.println("I play");
    }

    @Override
    protected void eat() {
        System.out.println("I eat");
    }
}
class He extends PatternMethod{
    @Override
    protected void wash() {
        System.out.println("He wash");
    }

    @Override
    protected void cut() {
        System.out.println("He cut");
    }

    @Override
    protected void play() {
        System.out.println("He play");
    }

    @Override
    protected void eat() {
        System.out.println("He eat");
    }
}

